package com.appcenter.application.controller;

import com.appcenter.application.dto.orgs.OrgDto;
import com.appcenter.application.expand.RedisUtil;
import com.appcenter.application.input.Job.GetResultJobInput;
import com.appcenter.application.input.Job.GetResultJobsInput;
import com.appcenter.application.input.app.GetAppsInput;
import com.appcenter.application.input.externalapi.*;
import com.appcenter.application.input.orguser.GetOrgUsersInput;
import com.appcenter.application.input.permission.GetPermissionsServiceInput;
import com.appcenter.application.output.externalapi.GetOrgsOutput;
import com.appcenter.application.service.AppService;
import com.appcenter.application.service.ExternalAPISercive;
import com.appcenter.application.service.PermissionService;
import com.appcenter.jz.app.CurrentUser;
import com.appcenter.jz.config.ErrorJsonResult;
import com.appcenter.jz.config.JsonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("services/api")
@Api(value = "开放API接口", description = "开放API接口")
public class ExternalAPIController {
    @Autowired
    ExternalAPISercive externalAPISercive;
    @Autowired
    AppService appSercive;
    @Autowired
    PermissionService permissionService;


    @Autowired
    RedisUtil redisUtil;

    @ApiOperation(value = "根据部门取人员", notes = "获取全部部门信息", produces = "application/json")
    @PostMapping("/getorgusers")
    public ResponseEntity<JsonResult> GetOrgUsers(@RequestBody GetOrgUsersInput input) throws Exception {
        //throw new ErrorJsonResult("1000001", "捕获异常信息");
        JsonResult r = new JsonResult();
        try {
            r.setSuccess(true);
            r.setResult(externalAPISercive.GetOrgUsers(input));
        } catch (ErrorJsonResult e) {
            r.setResult(e.getClass().getName() + ":" + e.getMessage());
            r.setError(e);
            e.printStackTrace();
            return ResponseEntity.ok(r);
        } catch(Exception e){
            ErrorJsonResult curErrorJsonResult=new ErrorJsonResult("100",e.getMessage().toString());
            r.setError(curErrorJsonResult);
            e.printStackTrace();
            return ResponseEntity.status(500).body(r);
        }
        return ResponseEntity.ok(r);
    }

    @ApiOperation(value = "获取人员信息", notes = "获取人员信息", produces = "application/json")
    @PostMapping("/getuserdetaile")
    public ResponseEntity<JsonResult> GetUserDetaile(@RequestBody GetUsersDetaileInput input) throws Exception {
        //throw new ErrorJsonResult("1000001", "捕获异常信息");
        JsonResult r = new JsonResult();
        try {
            r.setSuccess(true);
            r.setResult(externalAPISercive.GetUserDetaile(input));
        } catch (ErrorJsonResult e) {
            r.setResult(e.getClass().getName() + ":" + e.getMessage());
            r.setError(e);
            e.printStackTrace();
            return ResponseEntity.ok(r);
        } catch(Exception e){
            ErrorJsonResult curErrorJsonResult=new ErrorJsonResult("100",e.getMessage().toString());
            r.setError(curErrorJsonResult);
            e.printStackTrace();
            return ResponseEntity.status(500).body(r);
        }
        return ResponseEntity.ok(r);
    }

    @ApiOperation(value = "获取组织架构信息", notes = "获取组织架构信息", produces = "application/json")
    @PostMapping("/getorgs")
    public ResponseEntity<JsonResult> GetOrgs(@RequestBody GetOrgsInput input) throws Exception {
        //throw new ErrorJsonResult("1000001", "捕获异常信息");
        JsonResult r = new JsonResult();
        try {
            r.setSuccess(true);
            r.setResult(externalAPISercive.GetOrgs(input));
        } catch (ErrorJsonResult e) {
            r.setResult(e.getClass().getName() + ":" + e.getMessage());
            r.setError(e);
            e.printStackTrace();
            return ResponseEntity.ok(r);
        } catch(Exception e){
            ErrorJsonResult curErrorJsonResult=new ErrorJsonResult("100",e.getMessage().toString());
            r.setError(curErrorJsonResult);
            e.printStackTrace();
            return ResponseEntity.status(500).body(r);
        }
        return ResponseEntity.ok(r);
    }

    @ApiOperation(value = "获取单个部门信息", notes = "获取单个部门信息", produces = "application/json")
    @PostMapping("/getorg")
    public ResponseEntity<JsonResult> GetOrg(@RequestBody GetOrgInput input) throws Exception {
        //throw new ErrorJsonResult("1000001", "捕获异常信息");
        JsonResult r = new JsonResult();
        try {
            r.setSuccess(true);
            r.setResult(externalAPISercive.GetOrg(input));
        } catch (ErrorJsonResult e) {
            r.setResult(e.getClass().getName() + ":" + e.getMessage());
            r.setError(e);
            e.printStackTrace();
            return ResponseEntity.ok(r);
        } catch(Exception e){
            ErrorJsonResult curErrorJsonResult=new ErrorJsonResult("100",e.getMessage().toString());
            r.setError(curErrorJsonResult);
            e.printStackTrace();
            return ResponseEntity.status(500).body(r);
        }
        return ResponseEntity.ok(r);
    }

    @ApiOperation(value = "获取岗位信息", notes = "获取岗位信息", produces = "application/json")
    @PostMapping("/getjobs")
    public ResponseEntity<JsonResult> GetJobs(@RequestBody GetResultJobsInput input) throws Exception {
        //throw new ErrorJsonResult("1000001", "捕获异常信息");
        JsonResult r = new JsonResult();
        try {
            r.setSuccess(true);
            r.setResult(externalAPISercive.GetJobs(input));
        } catch (ErrorJsonResult e) {
            r.setResult(e.getClass().getName() + ":" + e.getMessage());
            r.setError(e);
            e.printStackTrace();
            return ResponseEntity.ok(r);
        } catch(Exception e){
            ErrorJsonResult curErrorJsonResult=new ErrorJsonResult("100",e.getMessage().toString());
            r.setError(curErrorJsonResult);
            e.printStackTrace();
            return ResponseEntity.status(500).body(r);
        }
        return ResponseEntity.ok(r);
    }

    @ApiOperation(value = "获取单个岗位信息", notes = "获取单个岗位信息", produces = "application/json")
    @PostMapping("/getjob")
    public ResponseEntity<JsonResult> GetJob(@RequestBody GetResultJobInput input) throws Exception {
        //throw new ErrorJsonResult("1000001", "捕获异常信息");
        JsonResult r = new JsonResult();
        try {
            r.setSuccess(true);
            r.setResult(externalAPISercive.GetJob(input));
        } catch (ErrorJsonResult e) {
            r.setResult(e.getClass().getName() + ":" + e.getMessage());
            r.setError(e);
            e.printStackTrace();
            return ResponseEntity.ok(r);
        } catch(Exception e){
            ErrorJsonResult curErrorJsonResult=new ErrorJsonResult("100",e.getMessage().toString());
            r.setError(curErrorJsonResult);
            e.printStackTrace();
            return ResponseEntity.status(500).body(r);
        }
        return ResponseEntity.ok(r);
    }

    @ApiOperation(value = "获取全部人员信息", notes = "获取全部人员信息", produces = "application/json")
    @PostMapping("/getusers")
    public ResponseEntity<JsonResult> GetUsers(@RequestBody GetUsersInput input) throws Exception {
        //throw new ErrorJsonResult("1000001", "捕获异常信息");
        JsonResult r = new JsonResult();
        try {
            r.setSuccess(true);
            r.setResult(externalAPISercive.GetUsers(input));
        } catch (ErrorJsonResult e) {
            r.setResult(e.getClass().getName() + ":" + e.getMessage());
            r.setError(e);
            e.printStackTrace();
            return ResponseEntity.ok(r);
        } catch(Exception e){
            ErrorJsonResult curErrorJsonResult=new ErrorJsonResult("100",e.getMessage().toString());
            r.setError(curErrorJsonResult);
            e.printStackTrace();
            return ResponseEntity.status(500).body(r);
        }
        return ResponseEntity.ok(r);
    }

    @ApiOperation(value = "获取单个人员信息", notes = "获取单个人员信息", produces = "application/json")
    @PostMapping("/getuser")
    public ResponseEntity<JsonResult> GetUser(@RequestBody GetUserInput input) throws Exception {
        //throw new ErrorJsonResult("1000001", "捕获异常信息");
        JsonResult r = new JsonResult();
        try {
            r.setSuccess(true);
            r.setResult(externalAPISercive.GetUser(input));
        } catch (ErrorJsonResult e) {
            r.setResult(e.getClass().getName() + ":" + e.getMessage());
            r.setError(e);
            e.printStackTrace();
            return ResponseEntity.ok(r);
        } catch(Exception e){
            ErrorJsonResult curErrorJsonResult=new ErrorJsonResult("100",e.getMessage().toString());
            r.setError(curErrorJsonResult);
            e.printStackTrace();
            return ResponseEntity.status(500).body(r);
        }
        return ResponseEntity.ok(r);
    }

    @ApiOperation(value = "获取用户邮箱密码", notes = "获取用户邮箱密码", produces = "application/json")
    @PostMapping("/getuseremailpassword")
    public ResponseEntity<JsonResult> GetUserEmailPassword(@RequestBody GetUserEmailInput input) throws Exception {
        //throw new ErrorJsonResult("1000001", "捕获异常信息");
        JsonResult r = new JsonResult();
        try {
            r.setSuccess(true);
            r.setResult(externalAPISercive.GetUserEmailPassword(input));
        } catch (ErrorJsonResult e) {
            r.setResult(e.getClass().getName() + ":" + e.getMessage());
            r.setError(e);
            e.printStackTrace();
            return ResponseEntity.ok(r);
        } catch(Exception e){
            ErrorJsonResult curErrorJsonResult=new ErrorJsonResult("100",e.getMessage().toString());
            r.setError(curErrorJsonResult);
            e.printStackTrace();
            return ResponseEntity.status(500).body(r);
        }
        return ResponseEntity.ok(r);
    }

    //已完成
    @ApiOperation(value = "修改用户密码", notes = "修改用户密码", produces = "application/json")
    @PostMapping("/editpassword")
    public ResponseEntity<JsonResult> EditPassWord(@RequestBody EditPassWordInput input) throws Exception {
        //throw new ErrorJsonResult("1000001", "捕获异常信息");
        JsonResult r = new JsonResult();
        try {
            r.setSuccess(true);
            r.setResult(externalAPISercive.EditPassWord(input));


        } catch (ErrorJsonResult e) {
            r.setResult(e.getClass().getName() + ":" + e.getMessage());
            r.setError(e);
            e.printStackTrace();
            return ResponseEntity.ok(r);
        } catch(Exception e){
            ErrorJsonResult curErrorJsonResult=new ErrorJsonResult("100",e.getMessage().toString());
            r.setError(curErrorJsonResult);
            e.printStackTrace();
            return ResponseEntity.status(500).body(r);
        }
        return ResponseEntity.ok(r);
    }

    @ApiOperation(value = "查询同步数据标志位", notes = "查询同步数据标志位", produces = "application/json")
    @PostMapping("/getdatamark")
    public ResponseEntity<JsonResult> GetDataMark(@RequestBody GetDataMarkInput input) throws Exception {
        //throw new ErrorJsonResult("1000001", "捕获异常信息");
        JsonResult r = new JsonResult();
        try {
            r.setSuccess(true);
            r.setResult(externalAPISercive.GetDataMark(input));
        } catch (ErrorJsonResult e) {
            r.setResult(e.getClass().getName() + ":" + e.getMessage());
            r.setError(e);
            e.printStackTrace();
            return ResponseEntity.ok(r);
        } catch(Exception e){
            ErrorJsonResult curErrorJsonResult=new ErrorJsonResult("100",e.getMessage().toString());
            r.setError(curErrorJsonResult);
            e.printStackTrace();
            return ResponseEntity.status(500).body(r);
        }
        return ResponseEntity.ok(r);
    }

    @ApiOperation(value = "查询角色信息", notes = "查询角色信息", produces = "application/json")
    @PostMapping("/getroles")
    public ResponseEntity<JsonResult> GetRoles(@RequestBody GetRolesInput input) throws Exception {
        //throw new ErrorJsonResult("1000001", "捕获异常信息");
        JsonResult r = new JsonResult();
        try {
            r.setSuccess(true);
            r.setResult(externalAPISercive.GetRoles(input));
        } catch (ErrorJsonResult e) {
            r.setResult(e.getClass().getName() + ":" + e.getMessage());
            r.setError(e);
            e.printStackTrace();
            return ResponseEntity.ok(r);
        } catch(Exception e){
            ErrorJsonResult curErrorJsonResult=new ErrorJsonResult("100",e.getMessage().toString());
            r.setError(curErrorJsonResult);
            e.printStackTrace();
            return ResponseEntity.status(500).body(r);
        }
        return ResponseEntity.ok(r);
    }

    @ApiOperation(value = "查询应用的权限信息", notes = "查询应用的权限信息", produces = "application/json")
    @PostMapping("/getpermissions")
    public ResponseEntity<JsonResult> GetPermissions(@RequestBody GetPermissionsInput input) throws Exception {
        //throw new ErrorJsonResult("1000001", "捕获异常信息");
        JsonResult r = new JsonResult();
        try {
            r.setSuccess(true);
            r.setResult(externalAPISercive.GetPermissions(input));
        } catch (ErrorJsonResult e) {
            r.setResult(e.getClass().getName() + ":" + e.getMessage());
            r.setError(e);
            e.printStackTrace();
            return ResponseEntity.ok(r);
        } catch(Exception e){
            ErrorJsonResult curErrorJsonResult=new ErrorJsonResult("100",e.getMessage().toString());
            r.setError(curErrorJsonResult);
            e.printStackTrace();
            return ResponseEntity.status(500).body(r);
        }
        return ResponseEntity.ok(r);
    }

    @ApiOperation(value = "查询授权信息", notes = "查询授权信息", produces = "application/json")
    @PostMapping("/getwarrant")
    public ResponseEntity<JsonResult> GetWarrant(@RequestBody GetWarrantInput input) throws Exception {
        //throw new ErrorJsonResult("1000001", "捕获异常信息");
        JsonResult r = new JsonResult();
        try {
            r.setSuccess(true);
            r.setResult(externalAPISercive.GetWarrant(input));
        } catch (ErrorJsonResult e) {
            r.setResult(e.getClass().getName() + ":" + e.getMessage());
            r.setError(e);
            e.printStackTrace();
            return ResponseEntity.ok(r);
        } catch(Exception e){
            ErrorJsonResult curErrorJsonResult=new ErrorJsonResult("100",e.getMessage().toString());
            r.setError(curErrorJsonResult);
            e.printStackTrace();
            return ResponseEntity.status(500).body(r);
        }
        return ResponseEntity.ok(r);
    }

    @ApiOperation(value = "查询菜单信息", notes = "查询菜单信息", produces = "application/json")
    @PostMapping("/getmenus")
    public ResponseEntity<JsonResult> GetMenus(@RequestBody GetMenusInput input) throws Exception {
        //throw new ErrorJsonResult("1000001", "捕获异常信息");
        JsonResult r = new JsonResult();
        try {
            r.setSuccess(true);
            r.setResult(externalAPISercive.GetMenus(input));
        } catch (ErrorJsonResult e) {
            r.setResult(e.getClass().getName() + ":" + e.getMessage());
            r.setError(e);
            e.printStackTrace();
            return ResponseEntity.ok(r);
        } catch(Exception e){
            ErrorJsonResult curErrorJsonResult=new ErrorJsonResult("100",e.getMessage().toString());
            r.setError(curErrorJsonResult);
            e.printStackTrace();
            return ResponseEntity.status(500).body(r);
        }
        return ResponseEntity.ok(r);
    }

    /*@ApiOperation(value = "查询字典信息", notes = "查询字典信息", produces = "application/json")
    @PostMapping("/getdics")
    public ResponseEntity<JsonResult> GetDics(@RequestBody GetDicsInput input) throws Exception {
        //throw new ErrorJsonResult("1000001", "捕获异常信息");
        JsonResult r = new JsonResult();
        try {
            r.setSuccess(true);
            r.setResult(externalAPISercive.GetDics(input));
        } catch (ErrorJsonResult e) {
            r.setResult(e.getClass().getName() + ":" + e.getMessage());
            r.setError(e);
            e.printStackTrace();
            return ResponseEntity.ok(r);
        } catch(Exception e){
            ErrorJsonResult curErrorJsonResult=new ErrorJsonResult("100",e.getMessage().toString());
            r.setError(curErrorJsonResult);
            e.printStackTrace();
            return ResponseEntity.status(500).body(r);
        }
        return ResponseEntity.ok(r);
    }*/

    @ApiOperation(value = "忘记密码分配验证码", notes = "忘记密码分配验证码", produces = "application/json")
    @PostMapping("/assignverificationcode")
    public ResponseEntity<JsonResult> AssignVerificationCode(@RequestBody AssignVerificationCodeInput input) throws Exception {
        //throw new ErrorJsonResult("1000001", "捕获异常信息");
        JsonResult r = new JsonResult();
        try {
            r.setSuccess(true);
            r.setResult(externalAPISercive.AssignVerificationCode(input));
        } catch (ErrorJsonResult e) {
            r.setResult(e.getClass().getName() + ":" + e.getMessage());
            r.setError(e);
            e.printStackTrace();
            return ResponseEntity.ok(r);
        } catch(Exception e){
            ErrorJsonResult curErrorJsonResult=new ErrorJsonResult("100",e.getMessage().toString());
            r.setError(curErrorJsonResult);
            e.printStackTrace();
            return ResponseEntity.status(500).body(r);
        }
        return ResponseEntity.ok(r);
    }



    @ApiOperation(value = "修改邮箱密码分配验证码", notes = "修改邮箱密码分配验证码", produces = "application/json")
    @PostMapping("/emailassignverificationcode")
    public ResponseEntity<JsonResult> EmailAssignVerificationCode(@RequestBody AssignVerificationCodeInput input) throws Exception {
        //throw new ErrorJsonResult("1000001", "捕获异常信息");
        JsonResult r = new JsonResult();
        try {
            r.setSuccess(true);
            r.setResult(externalAPISercive.EmailAssignVerificationCode(input));
        } catch (ErrorJsonResult e) {
            r.setResult(e.getClass().getName() + ":" + e.getMessage());
            r.setError(e);
            e.printStackTrace();
            return ResponseEntity.ok(r);
        } catch(Exception e){
            ErrorJsonResult curErrorJsonResult=new ErrorJsonResult("100",e.getMessage().toString());
            r.setError(curErrorJsonResult);
            e.printStackTrace();
            return ResponseEntity.status(500).body(r);
        }
        return ResponseEntity.ok(r);
    }

    @ApiOperation(value = "验证验证码", notes = "验证验证码", produces = "application/json")
    @PostMapping("/verificationverificationcode")
    public ResponseEntity<JsonResult> VerificationVerificationCode(@RequestBody VerificationVerificationCodeInput input) throws Exception {
        //throw new ErrorJsonResult("1000001", "捕获异常信息");
        JsonResult r = new JsonResult();
        try {
            r.setSuccess(true);
            r.setResult(externalAPISercive.VerificationVerificationCode(input));
        } catch (ErrorJsonResult e) {
            r.setResult(e.getClass().getName() + ":" + e.getMessage());
            r.setError(e);
            e.printStackTrace();
            return ResponseEntity.ok(r);
        } catch(Exception e){
            ErrorJsonResult curErrorJsonResult=new ErrorJsonResult("100",e.getMessage().toString());
            r.setError(curErrorJsonResult);
            e.printStackTrace();
            return ResponseEntity.status(500).body(r);
        }
        return ResponseEntity.ok(r);
    }

    @ApiOperation(value = "修改邮箱密码", notes = "修改邮箱密码", produces = "application/json")
    @PostMapping("/editemailpassword")
    public ResponseEntity<JsonResult> EditEmailPassWord(@RequestBody EditEmailPassWordInput input) throws Exception {
        //throw new ErrorJsonResult("1000001", "捕获异常信息");
        JsonResult r = new JsonResult();
        try {
            r.setSuccess(true);
            r.setResult(externalAPISercive.EditEmailPassWord (input));
        } catch (ErrorJsonResult e) {
            r.setResult(e.getClass().getName() + ":" + e.getMessage());
            r.setError(e);
            e.printStackTrace();
            return ResponseEntity.ok(r);
        } catch(Exception e){
            ErrorJsonResult curErrorJsonResult=new ErrorJsonResult("100",e.getMessage().toString());
            r.setError(curErrorJsonResult);
            e.printStackTrace();
            return ResponseEntity.status(500).body(r);
        }
        return ResponseEntity.ok(r);
    }

    @ApiOperation(value = "重置密码", notes = "重置密码", produces = "application/json")
    @PostMapping("/resetPassword")
    public ResponseEntity<JsonResult> resetPassword(@RequestBody ResetPasswordInput  input) throws Exception {
        //throw new ErrorJsonResult("1000001", "捕获异常信息");
        JsonResult r = new JsonResult();
        try {
            r.setSuccess(true);
            r.setResult(externalAPISercive.resetPassWord (input));
        } catch (ErrorJsonResult e) {
            r.setResult(e.getClass().getName() + ":" + e.getMessage());
            r.setError(e);
            e.printStackTrace();
            return ResponseEntity.ok(r);
        } catch(Exception e){
            ErrorJsonResult curErrorJsonResult=new ErrorJsonResult("100",e.getMessage().toString());
            r.setError(curErrorJsonResult);
            e.printStackTrace();
            return ResponseEntity.status(500).body(r);
        }
        return ResponseEntity.ok(r);
    }


    @ApiOperation(value = "获取全部系统信息", notes = "获取全部系统信息", produces = "application/json")
    @PostMapping("/getapps")
    public ResponseEntity<JsonResult> GetApps(@RequestBody GetAppsInput input) throws Exception {
        //throw new ErrorJsonResult("1000001", "捕获异常信息");
        JsonResult r = new JsonResult();
        try {
            r.setSuccess(true);
            r.setResult(externalAPISercive.GetApps(input));
        } catch (ErrorJsonResult e) {
            r.setResult(e.getClass().getName() + ":" + e.getMessage());
            r.setError(e);
            e.printStackTrace();
            return ResponseEntity.ok(r);
        } catch(Exception e){
            ErrorJsonResult curErrorJsonResult=new ErrorJsonResult("100",e.getMessage().toString());
            r.setError(curErrorJsonResult);
            e.printStackTrace();
            return ResponseEntity.status(500).body(r);
        }
        return ResponseEntity.ok(r);
    }

   // @ApiOperation(value = "获取权限", notes = "获取权限",produces = "application/json")
   // @PostMapping("/getPermissions")
   // public ResponseEntity<JsonResult> GetPermissions(@RequestBody GetPermissionsServiceInput input) throws Exception {
   //     //throw new ErrorJsonResult("1000001", "捕获异常信息");
   //     JsonResult r = new JsonResult();
   //     try {
   //         r.setResult(permissionService.GetPermissions(input));
   //     } catch (ErrorJsonResult e) {
   //         r.setResult(e.getClass().getName() + ":" + e.getMessage());
   //         r.setError(e);
   //         e.printStackTrace();
   //         return ResponseEntity.ok(r);
   //     } catch(Exception e){
   //         ErrorJsonResult curErrorJsonResult=new ErrorJsonResult("100",e.getMessage().toString());
   //         r.setError(curErrorJsonResult);
   //         e.printStackTrace();
   //         return ResponseEntity.status(500).body(r);
   //     }
   //     return ResponseEntity.ok(r);
   // }
//
    @ApiOperation(value = "根据岗位取人员", notes = "根据岗位取人员",produces = "application/json")
    @PostMapping("/getjobusers")
    public ResponseEntity<JsonResult> GetJobUsers(@RequestBody com.appcenter.application.input.user.GetUsersInput input) throws Exception {
        //throw new ErrorJsonResult("1000001", "捕获异常信息");
        JsonResult r = new JsonResult();
        try {
            r.setResult(externalAPISercive.GetJobUsers(input));
        } catch (ErrorJsonResult e) {
            r.setResult(e.getClass().getName() + ":" + e.getMessage());
            r.setError(e);
            e.printStackTrace();
            return ResponseEntity.ok(r);
        } catch(Exception e){
            ErrorJsonResult curErrorJsonResult=new ErrorJsonResult("100",e.getMessage().toString());
            r.setError(curErrorJsonResult);
            e.printStackTrace();
            return ResponseEntity.status(500).body(r);
        }
        return ResponseEntity.ok(r);
    }

    @ApiOperation(value = "业务系统获取人员信息", notes = "业务系统获取人员信息", produces = "application/json")
    @PostMapping("/getbusinessusers")
    public ResponseEntity<JsonResult> GetBusinessSystemUsers(@RequestBody BusinessSystemUsersInput input) throws Exception {
        //throw new ErrorJsonResult("1000001", "捕获异常信息");
        JsonResult r = new JsonResult();
        try {
            r.setSuccess(true);
            r.setResult(externalAPISercive.BusinessSystemUsers(input));
        } catch (ErrorJsonResult e) {
            r.setResult(e.getClass().getName() + ":" + e.getMessage());
            r.setError(e);
            e.printStackTrace();
            return ResponseEntity.ok(r);
        } catch(Exception e){
            ErrorJsonResult curErrorJsonResult=new ErrorJsonResult("100",e.getMessage().toString());
            r.setError(curErrorJsonResult);
            e.printStackTrace();
            return ResponseEntity.status(500).body(r);
        }
        return ResponseEntity.ok(r);
    }

    @ApiOperation(value = "业务系统获取岗位信息", notes = "业务系统获取岗位信息", produces = "application/json")
    @PostMapping("/getbusinessjobs")
    public ResponseEntity<JsonResult> GetBusinessSystemJobss(@RequestBody BusinessSystemJobsInput input) throws Exception {
        //throw new ErrorJsonResult("1000001", "捕获异常信息");
        JsonResult r = new JsonResult();
        try {
            r.setSuccess(true);
            r.setResult(externalAPISercive.BusinessSystemJobs(input));
        } catch (ErrorJsonResult e) {
            r.setResult(e.getClass().getName() + ":" + e.getMessage());
            r.setError(e);
            e.printStackTrace();
            return ResponseEntity.ok(r);
        } catch(Exception e){
            ErrorJsonResult curErrorJsonResult=new ErrorJsonResult("100",e.getMessage().toString());
            r.setError(curErrorJsonResult);
            e.printStackTrace();
            return ResponseEntity.status(500).body(r);
        }
        return ResponseEntity.ok(r);
    }




    @ApiOperation(value = "模拟登陆", notes = "模拟登陆", produces = "application/json")
    @PostMapping("/login")
    public ResponseEntity<JsonResult> Login(@RequestBody LoginInput input) throws Exception {
        //throw new ErrorJsonResult("1000001", "捕获异常信息");
        JsonResult r = new JsonResult();
        try {
            r.setSuccess(true);
            CurrentUser.setUserId(input.getUserCode());
            CurrentUser.setUserName(input.getUserName());
            CurrentUser.setUserCode(input.getUserCode());
            r.setResult("模拟成功");
        } catch (ErrorJsonResult e) {
            r.setResult(e.getClass().getName() + ":" + e.getMessage());
            r.setError(e);
            e.printStackTrace();
            return ResponseEntity.ok(r);
        } catch(Exception e){
            ErrorJsonResult curErrorJsonResult=new ErrorJsonResult("100",e.getMessage().toString());
            r.setError(curErrorJsonResult);
            e.printStackTrace();
            return ResponseEntity.status(500).body(r);
        }
        return ResponseEntity.ok(r);
    }



}
